import { Controller, Get, Post, Body, Param, Delete, Put } from '@nestjs/common';
import { Spec_Service } from './spec.service';
import { Spec_Create_Dto, Spec_Update_Dto } from './assets/spec.dto';
import { ApiTags } from '@nestjs/swagger';
import { util_Index_ReturnContent } from '@/common/util/index';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';

@Controller('/adm/spec')
@ApiTags('spec 规格属性')
export class Spec_Controller {
  constructor(private readonly spec_Service: Spec_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/spec/add Post',
  })
  async spec_Create(@Body() body: Spec_Create_Dto) {
    return util_Index_ReturnContent(await this.spec_Service.spec_Create(body));
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    //apiKey: '/adm/spec/list Get',
  })
  async spec_FindByPage() {
    return util_Index_ReturnContent(await this.spec_Service.spec_FindByPage());
  }

  @Get('/specsTypeId/:specsTypeId')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    summary: '获取规格属性类别下的所有规格属性',
    //apiKey: '/adm/spec/specsTypeId/:specsTypeId Get',
  })
  async spec_FindBySpecsType(@Param('specsTypeId') specsTypeId: string) {
    return util_Index_ReturnContent(await this.spec_Service.spec_FindBySpecsType(+specsTypeId));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/spec/update Put',
  })
  async spec_Update(@Body() body: Spec_Update_Dto) {
    return util_Index_ReturnContent(await this.spec_Service.spec_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/spec/delete/:id Delete',
  })
  async spec_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.spec_Service.spec_Remove(+id));
  }
}
